package 实验9;

import java.util.InputMismatchException;
import java.util.Random;
import java.util.Scanner;

public class ArrayIndexOutBoundsException {
	public static void main(String[] args) {
		int[] num = new int[100];
		Random r = new Random();
		int MaxInt = (int)Math.pow(2, 32);
		for(int i = 0;i < num.length; i++) {
			num[i] = r.nextInt(MaxInt);
		}
		
		
		Scanner s = new Scanner(System.in);
		boolean isCon = true;
		while (isCon) {
			try {
				System.out.print("请输入数组下标(0-99)：");
				int index = s.nextInt();
				System.out.print(num[index]);
				isCon = false;
			} catch (InputMismatchException e) {
				System.out.println("数组下标是一个整数！");
				s.nextLine();
			}
			catch (ArrayIndexOutOfBoundsException e) {
				System.out.println("数组下标介于0-99之间！");
				s.nextLine();
			}
		}
		s.close();
	}
}
